from app2 import dr_num
import os
import numpy as np
import cv2
import tqdm
BASE_PATH = os.path.dirname(os.path.abspath(__file__))
# 本工程路径
p_dic={}
for i in range(5):
    rrt='/Volumes/My Passport/0/'+str(i)+'/'
    p_dic[i]=['/Volumes/My Passport/0/'+str(i)+'/'+x for x in os.listdir(rrt)]

count=1
file = open('file_name2.txt', 'w')
file.write('名称')
file.write('\t')
file.write('正常概率')
file.write('\t')
file.write('第一级概率')
file.write('\t')
file.write('第二级概率')
file.write('\t')
file.write('第三级概率')
file.write('\t')
file.write('第四级概率')
file.write('\t')
file.write('微血管瘤数量')
file.write('\t')
file.write('硬性渗出数量')
file.write('\t')
file.write('出血数量')
file.write('\t')
file.write('棉絮斑数量')
file.write('\t')
file.write('微血管瘤像素点')
file.write('\t')
file.write('硬性渗出像素点')
file.write('\t')
file.write('出血像素点')
file.write('\t')
file.write('棉絮斑像素点')
file.write('\t')
file.write('分级结果')
file.write('\t')
file.write('\n')
for t in range(5):
    print(t)
    file.write('------------'+str(t)+'------------\n')
    count=0
    for i in tqdm.tqdm(p_dic[t]):
        img,prob,c,w=dr_num(i)
        count += 1
        #cv2.imwrite('/Users/zhoujiansheng/Desktop/lesion_statistics/result'+str(count)+'.jpg',img)
        file.write(i)
        file.write('\t')
        for m in prob:
            file.write(str(m))
            file.write('\t')
        for n in c:
            file.write(str(n))
            file.write('\t')
        for l in w:
            file.write(str(l))
            file.write('\t')
        file.write(str(np.argmax(prob)))
        file.write('\t')
        file.write('\n')
        if count == 50:
            count = 0
            break
file.close()